<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>Special Offer</title>
    </head>
    <body>
        <div id="special_offer_div">
        </div>
        <script>
            Ext.onReady(function(){
                var specialOfferForm = new Ext.form.FormPanel({
                    //baseCls: 'x-plain',
                    labelWidth: 55,
                    title: '发布特价信息',
                    bodyStyle: 'padding:3px 3px 0',
                    labelAlign: 'top',
                    frame: true,
                    //width: 600,
                    defaultType: 'textfield',
                    reader: new Ext.data.JsonReader({
                        root: 'root',
                        id: 'id'
                    }, [{
                        name: 'content'
                    }]),
                    items: [{
                        xtype: 'textarea',
                        hideLabel: true,
                        name: 'content',
                        height: 300,
                        anchor: '100% -53' // anchor width by percentage and height by raw adjustment
                    }],
                    buttons: [{
                        text: '保存',
                        handler: specialoffsubmit
                    }]
                });
                function specialoffsubmit(){
                    Ext.Ajax.request({
                        url: '/admin/setSpecialOffer',
                        params: specialOfferForm.form.getValues(true),
                        method: 'GET',
                        success: function(result, request){
                            if (result.responseText == "SUCCESS") {
                                Ext.MessageBox.alert('消息', '特价信息保存成功!');
                            }
                            else {
                                Ext.MessageBox.alert('消息', result.responseText);
                            }
                        },
                        failure: function(result, request){
                            Ext.MessageBox.alert('消息', '特价信息保存!');
                        }
                    });
                }
                specialOfferForm.render('special_offer_div');
                specialOfferForm.form.load({
                    url: '/admin/getSpecialOffer',
                    waitMsg: '正在载入数据...',
                    success: function(form, action){
                        //Ext.MessageBox.alert('提示信息', '特价信息加载成功');
                    },
                    failure: function(form, action){
                        Ext.MessageBox.alert('提示信息', '特价信息加载失败');
                    }
                });
            });
        </script>
    </body>
</html>
